import com.demo.component.AController;
import com.demo.component.ArticleController;
import com.demo.component.User;
import com.demo.component.Users;
import com.demo.controller.BlogController;
import com.demo.controller.StudentController;
import com.demo.model.Student;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class App {
    public static void main1(String[] args) {
//        //获取 spring 上下文
//        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        //获取 bean
//        com.demo.component.User user = context.getBean("user", com.demo.component.User.class);
//        //调用方法
//        user.sayHi();

        //BeanFactory context = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
          ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//        ArticleController controller = context.getBean("articleController",ArticleController.class);
//        System.out.println(controller.sayHi());
//        AController controller = context.getBean("AController",AController.class);
//        System.out.println(controller.sayHi());
//        User user = context.getBean("user", User.class);
//        System.out.println(user.sayHi());



//        Student student = context.getBean("s2",Student.class);
//        System.out.println(student);


//        StudentController sc = context.getBean("studentController",StudentController.class);
//        sc.sayHi();
        //使用属性注入获取 Bean 对象
//        BlogController controller = context.getBean("blogController",BlogController.class);
//        controller.test();

        //使用 @Bean 注解 配合五大类注解的到对象
//        User user = context.getBean("user1",User.class);
//        System.out.println(user);

//        User user = context.getBean("s1",User.class);
//
//        System.out.println(user);
//        AController controller = context.getBean("AController",AController.class);
//        System.out.println(controller.sayHi());


    }
}
